package com.mapper;

import com.entity.MaterialType;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author aiou
 * @since 2025-06-12
 */
@Mapper
public interface MaterialTypeMapper{

    //查询所有
    @Select("select * from material_type")
    List<MaterialType> list();


    //物料类别：根据物料编码获取物料类型
    @Select("select * from material_type where material_type_code = #{materialTypeCode}")
    MaterialType getone(String materialTypeCode);

    //物料类别：新增/修改物料
    @Insert("insert into material_type(material_type_code,material_type_name,formula) values(#{materialTypeCode},#{materialTypeName},#{formula})")
    boolean save(MaterialType materialType);
    //物料类别：新增/修改物料
    @Update("update material_type set material_type_code = #{materialTypeCode},material_type_name = #{materialTypeName},formula = #{formula} " +
            "where material_type_code = #{materialTypeCode}")
    boolean update(MaterialType materialType);

    //物料类别：删除物料
    @Delete("delete from material_type where material_type_id = #{id}")
    boolean deleteById(Integer id);
}
